package com.wanqing.config;

import com.wanqing.assistant.store.AdminChatMemoryStore;
import com.wanqing.assistant.store.UserChatMemoryStore;
import dev.langchain4j.memory.ChatMemory;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MemoryChatAssistantConfig {
    @Bean("userChatMemoryProvider")
    public ChatMemoryProvider userChatMemoryProvider(UserChatMemoryStore userChatMemoryStore) {
        return chat -> MessageWindowChatMemory.builder()
                .id(chat)
                .maxMessages(20)
                .chatMemoryStore(userChatMemoryStore) //配置持久化对象
                .build();
    }

    @Bean("adminChatMemoryProvider")
    public ChatMemoryProvider adminChatMemoryProvider(AdminChatMemoryStore adminChatMemoryStore) {
        return chat -> MessageWindowChatMemory.builder()
                .id(chat)
                .maxMessages(20)
                .chatMemoryStore(adminChatMemoryStore)//配置持久化对象
                .build();
    }


}